# Library
library(plyr)

# Read in pre-test data
lab <- read.csv("Raw_pretest_lab.csv",stringsAsFactors=F)
con <- read.csv("Raw_pretest_con.csv",stringsAsFactors=F)

##################################
### Organize variables 
##################################

# Labour

lab$manip_lab_mr <- as.numeric(mapvalues(lab$manip_lab_mr, c("Very moral","Somewhat moral",
                                                             "Neither moral nor pragmatic",
                                                             "Somewhat pragmatic","Very pragmatic"),
                                         5:1))
lab$strength_lab_mr <- as.numeric(mapvalues(lab$strength_lab_mr, c("Very believable","Somewhat believable",
                                                                   "Neither believable nor unbelievable",
                                                                   "Somewhat unbelievable","Very unbelievable"),
                                            5:1))

lab$manip_lab_pr <- as.numeric(mapvalues(lab$manip_lab_pr, c("Very moral","Somewhat moral",
                                                             "Neither moral nor pragmatic",
                                                             "Somewhat pragmatic","Very pragmatic"),
                                         5:1))
lab$strength_lab_pr <- as.numeric(mapvalues(lab$strength_lab_pr, c("Very believable","Somewhat believable",
                                                                   "Neither believable nor unbelievable",
                                                                   "Somewhat unbelievable","Very unbelievable"),
                                            5:1))

# Conservative

con$manip_con_mr <- as.numeric(mapvalues(con$manip_con_mr, c("Very moral","Somewhat moral",
                                                             "Neither moral nor pragmatic",
                                                             "Somewhat pragmatic","Very pragmatic"),
                                         5:1))
con$strength_con_mr <- as.numeric(mapvalues(con$strength_con_mr, c("Very believable","Somewhat believable",
                                                                   "Neither believable nor unbelievable",
                                                                   "Somewhat unbelievable","Very unbelievable"),
                                            5:1))

con$manip_con_pr <- as.numeric(mapvalues(con$manip_con_pr, c("Very moral","Somewhat moral",
                                                             "Neither moral nor pragmatic",
                                                             "Somewhat pragmatic","Very pragmatic"),
                                         5:1))
con$strength_con_pr <- as.numeric(mapvalues(con$strength_con_pr, c("Very believable","Somewhat believable",
                                                                   "Neither believable nor unbelievable",
                                                                   "Somewhat unbelievable","Very unbelievable"),
                                            5:1))

##################################
### Analyses
##################################

# Is moral rhetoric considered more moral?
t.test(lab$manip_lab_mr, lab$manip_lab_pr)
t.test(con$manip_con_mr, con$manip_con_pr)

# Are the two types of treatments equally believable?
t.test(lab$strength_lab_mr, lab$strength_lab_pr)
t.test(con$strength_con_mr, con$strength_con_pr)

# Between the moral rhetoric vignettes, is perceived morality higher in Labour data?
t.test(subset(lab,FL_91_DO=="Labour_mr")$manip_lab_mr, 
       subset(con,FL_91_DO=="Conservative_mr")$manip_con_mr)

# Between the moral rhetoric vignettes, is perceived credibility higher in Labour data?
t.test(subset(lab,FL_91_DO=="Labour_mr")$strength_lab_mr, 
       subset(con,FL_91_DO=="Conservative_mr")$strength_con_mr)




